package com.holyn.guofang.view.welcome;

import android.Manifest;
import android.content.Intent;
import android.os.Handler;

import com.holyn.guofang.R;
import com.holyn.guofang.model.sharepreference.AppSharePreference;
import com.holyn.guofang.view.BaseActivity;
import com.holyn.guofang.view.Login.LoginActivity;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.vondear.rxtools.RxActivityUtils;

import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;

public class WelcomeActivity extends BaseActivity {
    @Override
    protected int getLayoutResID() {
        return R.layout.activity_welcome;
    }

    @Override
    protected void onMyCreate() {

        new RxPermissions(RxActivityUtils.getActivityStack().lastElement())
                .request(Manifest.permission.READ_PHONE_STATE, Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.BLUETOOTH, Manifest.permission.INTERNET)
                .subscribe(aBoolean -> {

                    new Handler().postDelayed(() -> {
                        //判断是否为第一次登陆【引导页】
                        if (AppSharePreference.getIsFirstOpen(WelcomeActivity.this)){
                            startActivity(new Intent(WelcomeActivity.this,IntroduceActivity.class));
                            AppSharePreference.saveIsFirstOpen(WelcomeActivity.this, false);
                        } else {
                            startActivity(new Intent(WelcomeActivity.this,LoginActivity.class));
                        }
                        //startActivity(new Intent(WelcomeActivity.this,LoginActivity.class));
                        finish();
                    },2000);

                });




    }
}
